package com.wc.alorithm_blue_bridge._动态规划.线性DP.密码脱落;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/14 17:10
 * @description 密码脱落
 * https://www.lanqiao.cn/problems/124/learning/?page=1&first_category_id=1
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static String s;

    public static void main(String[] args) {
        String s = sc.next();
        String sReverse = " " + new StringBuffer(s).reverse().toString();
        s = " " + s;
        int length = s.length();
        int[][] dp = new int[length][length];
        for (int i = 1; i < length; i++) {
            for (int j = 1; j < length; j++) {
                if (s.charAt(i) == sReverse.charAt(j)) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }
        out.println(length - dp[length - 1][length - 1] - 1);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }
}